/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.produccion.DAO;

import com.produccion.DAO.Interfaces.SedeDaoInterface;
import com.produccion.TO.SedeTo;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

/**
 *
 * @author carlosdavid
 */
@Repository
public class SedeDao extends HibernateDaoSupport implements SedeDaoInterface {

    @Autowired
    public SedeDao(SessionFactory sessionFactory){
        super.setSessionFactory(sessionFactory);
    }
    
    
    @Override
    public List<SedeTo> listarSedes() {
        Session session=getHibernateTemplate().getSessionFactory().openSession();
        
        Query consulta=session.createSQLQuery("select idSede as idSede,descripcion as descripcion from sede").
                setResultTransformer(Transformers.aliasToBean(SedeTo.class));
        
    return consulta.list();
    }
    
}
